home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / Effect library / Demo ƒ / Reversed fades ƒ / Mr. Do outdone fade reversed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-11  |  3.3 KB  |  163 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        Mr. Do outdone fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8.  
  9. MSG Demo -- graphic effects demonstration program
  10. Copyright (C) 1992-4 Mark Pilgrim & Dave Blumenthal
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "msg timing.h"
  30.  
  31. #define    BoxSize    2
  32. #define CorrectTime 3
  33. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  34. #define theWindowWidth (boundsRect.right-boundsRect.left)
  35.  
  36. pascal short MrDoOutdoneFadeReversed(Rect boundsRect, Pattern *thePattern);
  37.  
  38. /* 25 regions on screen, in a 5 x 5 grid.  Regions alternate as to whether they
  39.    scroll up or down. */
  40.    
  41. pascal short MrDoOutdoneFadeReversed(Rect boundsRect, Pattern *thePattern)
  42. {
  43.     int            x, y;
  44.     int            vgap,hgap;
  45.     Rect        dest;
  46.     Rect        bounds[25];
  47.     
  48.     vgap=theWindowHeight/5;
  49.     hgap=theWindowWidth/5;
  50.     
  51.     for (x=0; x<25; x++)
  52.     {
  53.         switch (x)
  54.         {
  55.             case 0:
  56.             case 1:
  57.             case 2:
  58.             case 3:
  59.             case 4:
  60.                 bounds[x].top=0;
  61.                 break;
  62.             case 15:
  63.             case 16:
  64.             case 17:
  65.             case 18:
  66.             case 5:
  67.                 bounds[x].top=vgap;
  68.                 break;
  69.             case 14:
  70.             case 23:
  71.             case 24:
  72.             case 19:
  73.             case 6:
  74.                 bounds[x].top=vgap*2;
  75.                 break;
  76.             case 13:
  77.             case 22:
  78.             case 21:
  79.             case 20:
  80.             case 7:
  81.                 bounds[x].top=vgap*3;
  82.                 break;
  83.             case 12:
  84.             case 11:
  85.             case 10:
  86.             case 9:
  87.             case 8:
  88.                 bounds[x].top=vgap*4;
  89.                 break;
  90.         }
  91.         switch (x)
  92.         {
  93.             case 0:
  94.             case 15:
  95.             case 14:
  96.             case 13:
  97.             case 12:
  98.                 bounds[x].left=0;
  99.                 break;
  100.             case 1:
  101.             case 16:
  102.             case 23:
  103.             case 22:
  104.             case 11:
  105.                 bounds[x].left=hgap;
  106.                 break;
  107.             case 2:
  108.             case 17:
  109.             case 24:
  110.             case 21:
  111.             case 10:
  112.                 bounds[x].left=hgap*2;
  113.                 break;
  114.             case 3:
  115.             case 18:
  116.             case 19:
  117.             case 20:
  118.             case 9:
  119.                 bounds[x].left=hgap*3;
  120.                 break;
  121.             case 4:
  122.             case 5:
  123.             case 6:
  124.             case 7:
  125.             case 8:
  126.                 bounds[x].left=hgap*4;
  127.                 break;
  128.         }
  129.         bounds[x].bottom=bounds[x].top+vgap;
  130.         bounds[x].right=bounds[x].left+hgap;
  131.         OffsetRect(&(bounds[x]), boundsRect.left, boundsRect.top);
  132.     }
  133.     
  134.     for (x=BoxSize; x<vgap; x+=BoxSize)
  135.     {        
  136.         StartTiming();
  137.         for (y=0; y<25; y++)
  138.         {
  139.             if (!(y%2))   /* these scroll up */
  140.             {
  141.                 dest=bounds[y];
  142.                 dest.top=dest.bottom-BoxSize;
  143.                 
  144.                 ScrollRect(&bounds[y], 0, -BoxSize, 0L);
  145.                 FillRect(&dest, *thePattern);
  146.             }
  147.             else    /* these scroll down */
  148.             {
  149.                 dest=bounds[y];
  150.                 dest.bottom=dest.top+BoxSize;
  151.                 
  152.                 ScrollRect(&bounds[y], 0, BoxSize, 0L);
  153.                 FillRect(&dest, *thePattern);
  154.             }
  155.         }
  156.         TimeCorrection(CorrectTime);
  157.     }
  158.     
  159.     FillRect(&boundsRect, *thePattern);        /* in case we missed any bits */
  160.     
  161.     return 0;
  162. }
  163.